# TODO 浅拷贝
# 说明: 只拷贝对象最外层
# list = copy.copy() 返回拷贝数据结果
import copy

list1 = [1, 2, ['a', 'b']]
list2 = copy.copy(list1)
print(f'list1:{id(list1)}, list1[-1]:{id(list1[2])}')
print(f'list2:{id(list2)}, list2[-1]:{id(list2[2])}')

print('==' * 20)

# str
str1 = 'hello'
str2 = copy.copy(str1)
print(id(str1))
print(id(str2))

# TODO 深拷贝
import copy

# list copy.deepcopy() 里外都要拷贝
list1 = [1, 2, ['a', 'b']]
list2 = copy.deecopy(list1)
print(f'list1:{id(list1)}, list1[-1]:{id(list1[2])}')
print(f'list2:{id(list2)}, list2[-1]:{id(list2[2])}')
